package com.hualan.sfzyproject.controller;

import com.hualan.sfzyproject.domain.PsyKnowledge;
import com.hualan.sfzyproject.service.PsyKnowledgeService;
import com.hualan.sfzyproject.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/psyKnowledge")
public class PsyKnowledgeController {
    @Autowired
    public PsyKnowledgeService psyKnowledgeService;


    @RequestMapping("/selectByConsultantsId")
    public List<PsyKnowledge> selectByConsultantsId(int id) {
        return psyKnowledgeService.selectByConsultantsId(id);
    }

    @RequestMapping("/selectAll")
    public R selectAll(Integer page, Integer pageSize) {
        return R.ok(psyKnowledgeService.PsyKnowledgePageQuery(page,pageSize));
    }

    @RequestMapping("/deleteById")
    public R deleteById(int id) {
        return psyKnowledgeService.deleteById(id)!=0?R.success("删除成功"):R.error("删除失败");
    }

    @RequestMapping("/insert")
    public R insert(PsyKnowledge psyKnowledge) {
        return psyKnowledgeService.insert(psyKnowledge)!=0?R.success("添加成功"):R.error("添加失败");
    }
}
